<template>
	<view class="mine-container">
		<view class="top">
			<image class="set-icon" src="/static/imgs/mine/set-icon.png" mode="widthFix" @click="toSet"></image>
			<view class="user-info">
				<image class="user-head" src="/static/imgs/mine/user-head1.png" mode="widthFix"></image>
				<view class="info">
					<view class="name-ifno">
						<text>{{ userInfo ? userInfo.name : "" }}</text>
						
					</view>
					<view class="invitation-code">
						<view v-if="identity==0" style="display: flex; align-items: center;">
							<image src="/static/imgs/mine/1.png"
							style="width: 38rpx; height: 38rpx;" 
							></image>
							<text style="padding-left: 20rpx; color: #333; font-weight: 600;">
							{{ $t("普通用户") }}</text>
							
						</view>
						
						<view v-if="identity==5" style="display: flex; align-items: center;">
							<image
							src="/static/imgs/mine/3.png" 
							style="width: 38rpx; height: 38rpx;" ></image>
							<text style="padding-left: 20rpx; color: #333; font-weight: 600;">联创用户</text>
							
						</view>

						<view style="display: flex;" v-else >
							<image 
								src="/static/imgs/mine/2.png" 
								style="width: 38rpx; height: 38rpx;" 
								
								v-for="index in identity" :key="index"
							></image>
						</view>
						
						<text class="grade-txt" 
						style="padding-left: 20rpx; color: #333; font-weight: 600;">
						等级：{{ levelStr }}</text>
					</view>
				</view>
			</view>
		</view>
		
		<!-- <view class="invite" style="text-align: center;">
			<image src="../../static/imgs/mine/invite.png" style="width: 690rpx; height: 110rpx;"></image>
		</view> -->
		
		<view class="money-box">
			<view class="section">
				<view class="line"></view>{{ $t("我的钱包") }}USDT
			</view>
			<view class="money-menu">
				<view class="item" @click="navigite('../other/shareAward')">
					<view class="label">{{ $t("分享收益") }}</view>
					<view class="num">
						<text class="num-txt">{{ assetsInfo ? assetsInfo.using.toFixed(2) : 0 }}</text>
						<!-- <text>USDT</text> -->
					</view>
				</view>
				<view class="item line" @click="navigite('../other/serviceAward')">
					<view class="label">服务费</view>
					<view class="num">
						<text class="num-txt">{{ assetsInfo ? assetsInfo.bail.toFixed(2) : 0 }}</text>
						<!-- <text>USDT</text> -->
					</view>
				</view>
				<view class="item" @click="navigite('/pages/index/income')">
					<view class="label">{{ $t("量化收益") }}</view>
					<view class="num">
						<text class="num-txt">{{ profit.toFixed(2) }}</text>
						<!-- <text>USDT</text> -->
					</view>
				</view>
			</view>
		</view>
		<view class="menu">
		  <view
		    class="item"
		    v-for="(item, index) in menulist"
		    :key="index"
		    @click="jump(item)"
		  >
		    <view class="label">
		      <image class="menu-icon" :src="item.icon" mode="widthFix"></image>
		      <text>{{ item.label }}</text>
		    </view>
		    <view class="status" v-if="index < 1">
		      {{ item.status }}
		    </view>
		  </view>
		</view> 
		<!-- 

    

    -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// menulist: [{
				// 		label: this.$t('激活现货量化'),
				// 		icon: '/static/imgs/mine/turn-money-icon.png',
				// 		status: this.$t('未激活'),
				// 		method: 'navigateTo',
				// 		url: '/pages/activate/spotGoods'
				// 	},
				// 	// {
				// 	// 	label: '激活合约量化',
				// 	// 	icon: '/static/imgs/mine/books-icon.png',
				// 	// 	status: '未激活',
				// 	// 	method: 'navigateTo',
				// 	// 	url: '', ///pages/activate/contract
				// 	// },
				// 	{
				// 		label: this.$t('充值'),
				// 		icon: '/static/imgs/mine/recharge-icon.png',
				// 		status: '',
				// 		method: 'navigateTo',
				// 		url: '/pages/finance/recharge'
				// 	},
				// 	{
				// 		label: this.$t('提现'),
				// 		icon: '/static/imgs/mine/extract-icon.png',
				// 		status: '',
				// 		method: 'navigateTo',
				// 		url: '/pages/finance/extract'
				// 	},
				// 	{
				// 		label: this.$t('提现明细'),
				// 		icon: '/static/imgs/mine/details-icon.png',
				// 		status: '',
				// 		method: 'navigateTo',
				// 		url: '/pages/finance/extract-details'
				// 	},
				// 	// {
				// 	// 	label: '身份认证',
				// 	// 	icon: '/static/imgs/mine/auth-head.png',
				// 	// 	status: ''
				// 	// }
				// ],
				userInfo: null,
				xhStatus: false, //现货激活量
				hyStatus: false, //合约激活量
				assetsInfo: {},
				profit: 0,
				levelStr: "",
				identity: 0,

			};
		},
		computed: {
			menulist() {
				return [{
						label: this.$t("激活现货量化"),
						icon: "/static/imgs/mine/turn-money-icon.png",
						status: this.$t("未激活"),
						method: "navigateTo",
						url: "/pages/activate/spotGoods",
					},
					{
						label: "团队",
						icon: "/static/imgs/mine/team.png",
						status: "",
						method: "navigateTo",
						url: "/pages/finance/team",
					},
					{
						label: this.$t("充值"),
						icon: "/static/imgs/mine/recharge-icon.png",
						status: "",
						method: "navigateTo",
						url: "/pages/finance/recharge",
					},
					{
						label: "充值明细",
						icon: "/static/imgs/mine/cDetail.png",
						status: "",
						method: "navigateTo",
						url: "/pages/finance/recharge-details",
					},
					{
						label: this.$t("提现"),
						icon: "/static/imgs/mine/extract-icon.png",
						status: "",
						method: "navigateTo",
						url: "/pages/finance/extract",
					},
					{
						label: this.$t("提现明细"),
						icon: "/static/imgs/mine/details-icon.png",
						status: "",
						method: "navigateTo",
						url: "/pages/finance/extract-details",
					},
					// {
					// 	label: '身份认证',
					// 	icon: '/static/imgs/mine/auth-head.png',
					// 	status: ''
					// }
				];
			},
		},
		methods: {
			jump(item) {
				if (!item.url) return;
				uni[item.method]({
					url: item.url,
				});
			},
			navigite(url){
				uni.navigateTo({
					url: url
				})
			},
			toSet() {
				console.log("kkk")
				uni.navigateTo({
					url: "/pages/set/system",
				});
			},
			copy() {
				this.$util.copy(this.userInfo.inviteCode);
			},

			getUserBaseInfo() {
				this.$http
					.post(`/front/user/baseInfo`)
					.then((res) => {
						if (res) {
							this.userInfo = res.obj.user;
							this.levelStr = res.obj.teamLevel.levelStr
							this.identity = res.obj.teamLevel.identity
							uni.setStorageSync("apiStatus", res.obj.apiStatus);
							this.profit = res.obj.profit;
							setTimeout(()=>{
								this.menulist[0].status = res.obj.contractActive ? this.$t("已激活") : this.$t("未激活");
								this.$forceUpdate()
							}, 200)
							
							console.log(this.menulist[0].status)
						}
					})
					.catch((err) => {
						console.error(err);
					});
			},
			// 获取用户资产
			getUserAssets() {
				this.$http
					.post(`/front/assets/assets`)
					.then((res) => {
						console.log(res, 333);

						if (res.code === 0) {
							this.assetsInfo = res.obj.wallet;
						}
					})
					.catch((err) => {
						console.log(err);
					});
			},
		},
		onLoad() {},
		onShow() {
			this.getUserBaseInfo();
			this.getUserAssets();
			this.switchTabLang();
		},
	};
</script>

<style>
	page {
		background-color: #121325;
	}
</style>

<style lang="scss" scoped>
	.mine-container {
		width: 100%;
		height: 100%;
		background: url("../../static/imgs/bg.png") no-repeat;
		background-size: 100% 100%;
		box-sizing: border-box;
		position: fixed;

		.place {
			height: calc(var(--status-bar-height) + 92rpx);
		}

		.top {
			position: relative;
			width: 100%;
			height: 300rpx;

			.set-icon {
				position: absolute;
				top: 88rpx;
				right: 40rpx;
				width: 56rpx;
				height: 52rpx;
				z-index: 999;
			}

			.user-info {
				position: relative;
				top: 100rpx;
				width: 100%;
				padding: 0 25rpx;
				margin-left: 16rpx;
				display: flex;
				align-items: center;

				.user-head {
					width: 116rpx;
					height: 116rpx;
					margin-right: 28rpx;
				}

				.name-ifno {
					display: flex;
					align-items: center;
					font-size: $uni-font-size-36;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333;
					margin-bottom: 20rpx;

					.grade-icon {
						width: 33rpx;
						height: 33rpx;
						margin: 0 14rpx;
					}

					.grade-txt {
						font-size: 24rpx;
					}
				}

				.invitation-code {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 300;
					color: #666;

					.copy-icon {
						width: 34rpx;
						height: 36rpx;
						margin-left: 25rpx;
						vertical-align: middle;
					}
				}
			}
		}

		.money-box {
			width: 690rpx;
			background: linear-gradient(180deg, #F8D7F4 0%, #FFE4E4 99%);
			box-shadow: 0rpx 4rpx 10rpx 0px rgba(29, 70, 117, 0.1);
			border-radius: 16rpx;
			box-sizing: border-box;
			margin: 0 auto;
			padding: 30rpx;
			margin-top: -50rpx;
			.section {
				display: flex;
				align-items: center;
				
				font-size: $uni-font-size-36;
				font-family: PingFang SC;
				font-weight: 400;
				color: #333333;
			}

			.money-menu {
				display: flex;
				padding: 30rpx;
				background: #fff;
				margin: 30rpx auto 0;
				border-radius: 20rpx;
				.item {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 300;
					color: $uni-text-color-fff;

					.label {
						margin-bottom: 20rpx;
						color: #333;
					}

					.num {
						font-size: $uni-font-size-30;
						color: #333;
						font-weight: 600;
						.num-txt {
							margin-right: 10rpx;
							color: #333;
							font-weight: 600;
						}
					}
				}

				.line {
					border-left: 2rpx solid #5f5f6a;
					border-right: 2rpx solid #5f5f6a;
				}
			}
		}

		.menu {
			width: 700rpx;
			margin: 20rpx auto;
			padding: 40rpx 30rpx;
			background: #fff;
			border-radius: 20rpx;
			box-sizing: border-box;

			.item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 35rpx;
				font-size: $uni-font-size-32;
				font-family: PingFang SC;
				font-weight: 400;
				color: #333;

				.menu-icon {
					width: 36rpx;
					margin-right: 18rpx;
					vertical-align: middle;
				}

				.status {
					font-weight: 300;
					color: #333;
				}
			}
			.item:nth-last-child(1) {
				margin-bottom: 0;
			}
		}
	}
</style>